package com.wangzifan.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wangzifan.entity.Grade;
import com.wangzifan.entity.PageBean;
import com.wangzifan.entity.Teacher;
import com.wangzifan.mapper.TeacherMapper;
import com.wangzifan.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TeacherServiceImpl implements TeacherService {
    @Autowired
    private TeacherMapper teacherMapper;

    @Override
    public PageBean page(Integer page, Integer pageSize) {
        //1. 设置分页参数
        PageHelper.startPage(page,pageSize);
        List<Teacher> teachers = teacherMapper.queryTeacher();
        Page<Teacher> p = (Page<Teacher>) teachers;

        PageBean pageBean = new PageBean(p.getTotal(), p.getResult());
        return pageBean;
    }

    @Override
    public Teacher queryTeacherById(Integer id) {
        return teacherMapper.queryTeacherById(id);
    }

    @Override
    public void deleteTeacher(List<Integer> ids) {
        teacherMapper.deleteTeacher(ids);
    }

    @Override
    public void addTeacher(Teacher teacher) {
        teacherMapper.addTeacher(teacher);
    }

    @Override
    public void updateTeacher(Teacher teacher) {
        teacherMapper.updateTeacher(teacher);
    }
}
